package controllers

import (
	"fmt"
	beego "github.com/beego/beego/v2/server/web"
	"test/models"
)

type MainController struct {
	beego.Controller
}

type Res struct {
	Cre  int
	Msg  string
	Data interface{}
}

func (c *MainController) Get() {

	get := models.Client.Get("2206a")
	fmt.Println(get)

	c.Data["json"] = Res{200, "获取成功", get.Val()}
	c.ServeJSON(true)

}

func (c *MainController) Set() {
	models.Client.Set("2206a", "徐新志", 0)
	models.Client.Set("2206a", "马航", 0)
	c.Data["json"] = Res{200, "数据存储成功", nil}
	c.ServeJSON(true)
}
